package feed;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.GetMethod;

class UserAgent
{
    def client = new HttpClient();

    def fetchUrl(url) {
      try {
        // Use HTTPClient for web requests since the server requires authentication
        //credentials = new UsernamePasswordCredentials(email, password);
        //client.getState().setCredentials("Bloglines RPC", server, credentials);
        def get = new GetMethod(url);
        get.setDoAuthentication(true);
        client.executeMethod(get);
        return get.getResponseBodyAsString();
      } catch (Exception e) {
        println "Error retrieving <${url}>: ${e}";
        return "";
      }
    }
}

